var clip = null;
		
function $(id) { return document.getElementById(id); }

function toggleIdDisplay(id) {
    if (document.getElementById(id).style.display.match(/none/)) {
        document.getElementById(id).style.display = 'block';
        }
    else {
        document.getElementById(id).style.display = 'none';
    }
}

function XmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXOject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your browser doesn't support the XmlHttpRequest Object");
	}
}

var asyObj = XmlHttpRequestObject();

function sayHello() {
	if (asyObj.readyState == 4 || asyObj.readyState == 0) {
		asyObj.open("POST",'http://127.0.0.1:5000/ajax.ajax', true);
                asyObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                asyObj.send("one=Hello&two=World");
		asyObj.onreadystatechange = handleasyObj;
	}
}

function sayReload() {
	if (asyObj.readyState == 4 || asyObj.readyState == 0) {
		asyObj.open("POST",'http://127.0.0.1:5000/ajax.ajax', true);
                asyObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                asyObj.send("one=Reload");
		asyObj.onreadystatechange = handleasyObj;
	}
}

function handleasyObj() {
    if (asyObj.readyState == 4) {
        if (asyObj.responseText.match(/Reload/)) {
            console.log("gotit");
            location.reload('True');
        }
        else {
            console.log(asyObj.responseText);
            document.getElementById('ajaxw').innerHTML = asyObj.responseText;
        }
    }
}

function init() {

    clipd = new ZeroClipboard.Client();
    clipd.setHandCursor( false );
    clipd.addEventListener('load', function (client) {
        debugstr("Flash movie loaded and ready.");
        });

    clipd.addEventListener('complete', function (client, text) {
        debugstr("Copied text to clipboard: " + text );
        });

    clipd.addEventListener('mouseOver', function (client) {
            // update the text on mouse over
        clipd.setText( $('debugtab').value );
        });

    clipd.glue( 'd_clip_button_debug', 'd_clip_container_debug');




